/*
 * Copyright (C) 2004, Velocityme Partnership
 * TaskStateMachineValueActionForm.java
 *
 * Created on 09 October 2004, 02:34
 */

package com.velocityme.www.actionforms.nodeactionforms;

import com.velocityme.valueobjects.RoleValue;
import java.util.*;
import org.apache.struts.action.*;

/**
 *
 * @author  Robert
 */
public class TaskStateMachineValueActionForm extends NodeValueActionForm {
    
    private Integer[] m_unassignedRoleIds;
    private Integer[] m_interestedRoleIds;
    
    /** Creates a new instance of TaskStateMachineValueActionForm */
    public TaskStateMachineValueActionForm() {
    }
    
    public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) {
        m_interestedRoleIds = new Integer[0];
    }
    
    public Integer[] getUnassignedRoleIds() {
        return m_unassignedRoleIds;
    }
    
    public void setUnassignedRoleIds(Integer[] unassignedRoleIds) {
        m_unassignedRoleIds = unassignedRoleIds;
    }
    
    public Integer[] getInterestedRoleIds() {
        return m_interestedRoleIds;
    }
    
    public void setInterestedRoleIds(Integer[] interestedRoleIds) {
        m_interestedRoleIds = interestedRoleIds;
    }
    
    public RoleValue[] getInterestedRoleValues(RoleValue[] allRoleValues) {
        Map roleMap = new HashMap();
        for (int i = 0; i < allRoleValues.length; i++)
            roleMap.put(allRoleValues[i].getRoleId(), allRoleValues[i]);
        RoleValue[] roleValues = new RoleValue[m_interestedRoleIds.length];
        for (int i = 0; i < roleValues.length; i++) {
            roleValues[i] = (RoleValue)roleMap.get(m_interestedRoleIds[i]);
        }
        return roleValues;
    }
    
}
